// const jwt = require('jsonwebtoken');
// const SECRET_KEY = 'sjdfkasdjflkj'
// // 1. 生成let token = jwt.sign(要加密的信息,key,{expireIn:过期时间})
// let token = jwt.sign({username:'atguigu',pwd:'123123', profile:'/upload/avatar.png'}, SECRET_KEY, {expiresIn:30});

// token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImF0Z3VpZ3UiLCJwd2QiOiIxMjMxMjMiLCJwcm9maWxlIjoiL3VwbG9hZC9hdmF0YXIucG5nIiwiaWF0IjoxNjgyNjY2NjA3LCJleHAiOjE2ODI2NjY2MTB9.89PbjMJkiD6zG_KFm0ZbKko4JSujbwd5y68VN7v3FIs'

// token加密一些信息[压缩格式等].被加密的数据.混合加密的信息[破解不了]
// eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImF0Z3VpZ3UiLCJwd2QiOiIxMjMxMjMiLCJwcm9maWxlIjoiL3VwbG9hZC9hdmF0YXIucG5nIiwiaWF0IjoxNjgyNjY2NjA3LCJleHAiOjE2ODI2NjY2MTB9.89PbjMJkiD6zG_KFm0ZbKko4JSujbwd5y68VN7v3FIs
// console.log(token);
// 2. 校验token   jwt.verify


// jwt.verify(token, SECRET_KEY, (err, data)=>{
//     if(err){
//         console.log(err);
//     }else{
//         console.log('data:' ,data);
//     }
// })

const {createToken, verifyToken} = require('../utils/tokenUtils')
let token = createToken({username:'atguigu'});
console.log(token);

verifyToken(token).then(data=>{
    console.log(data);
}).catch(error=>{
    console.log('error:', error);
})